coinsDialog <- function (){
	require(TeachingExtras)
	initializeDialog(title = gettext("Coins flipper", domain="R-RcmdrPlugin.TeachingExtras"))
	onOK <- function() {
		
		if (tclvalue(name) == "") {
			errorCondition(recall = samplesDialog, message = gettext("You must enter a name for the data frame.", domain="R-RcmdrPlugin.TeachingExtras"))
			return()
		}
		command <- paste(tclvalue(name), " <- samples(c(0,1), nsamples=",  tclvalue(nsamples), ", size=", tclvalue(size), ", sums=TRUE, means=FALSE)", sep = "")
		doItAndPrint(command)
		closeDialog()
		activateMenus()
		tkfocus(CommanderWindow())
	}
	OKCancelHelp(helpSubject = "samples")
	nameFrame <- tkframe(top)
	name <- tclVar("")
	nameField <- tkentry(nameFrame, width = "20", textvariable = name)
	tkgrid(tklabel(nameFrame, text = gettext("Data frame name: ", domain="R-RcmdrPlugin.TeachingExtras")), nameField, sticky = "w")
	tkgrid(nameFrame, sticky = "w")
	optionsFrame <- tkframe(top)
	nsamples <- tclVar("1")
	nsamplesField <- tkentry(optionsFrame, width = "10", textvariable = nsamples)
	tkgrid(labelRcmdr(optionsFrame, text=gettext("Number of coins: ", domain="R-RcmdrPlugin.TeachingExtras")),nsamplesField, sticky = "w")
	size <- tclVar("1")
	sizeField <- tkentry(optionsFrame, width = "10", textvariable = size)
	tkgrid(labelRcmdr(optionsFrame, text=gettext("Number of flips: ", domain="R-RcmdrPlugin.TeachingExtras")),sizeField, sticky = "w")
	tkgrid(optionsFrame, sticky="w")
	tkgrid(buttonsFrame, sticky = "w")
	dialogSuffix(rows = 3, columns = 1)
}

